package com.icehand.controller;

import com.icehand.model.User;
import com.icehand.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *
 * Created by icehand on 2017/5/11.
 */
@RestController
@RequestMapping("/user")
public class UserController {
	@Autowired
	private UserService userService;

	@RequestMapping(value="/save",method = RequestMethod.GET)
	public User save(@RequestParam(value = "name") String name){
		User user = new User();
		user.setName(name);
		System.out.println(name);
		userService.save(user);
		return user;
	}

	@RequestMapping("/find")
	public User findUserById(@RequestParam(value = "id") Integer id){
		return userService.findById(id);
	}

	@RequestMapping("/deleteCache")
	public void deleteUserCache(@RequestParam(value = "id")Integer id){
		userService.deleteFromCache(id);
	}
}
